﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aQuery
{
    public static class ActionQueueQuery
    {

        public static ActionQueue<T> EnqueueAction<T>(this ActionQueue<T> target, ActionAtTarget<T> action) where T : class
        {
            target.Actions.Enqueue(action);
            return target;
        }

        public static ActionQueue<T> EnqueueAction<T>(this T target, ActionAtTarget<T> action) where T : class
        {
            return new ActionQueue<T>(target).EnqueueAction(action);
        }

        public static ActionQueue<T> DequeueAction<T>(this ActionQueue<T> target) where T : class
        {
            return target.DequeueToExecute();
        }

        public static void ExecuteQueue<T>(this ActionQueue<T> target) where T : class
        {
            while (target.Actions.Count > 0)
            {
                target.DequeueAction();
            }
        }

        public static ActionQueue<T> SkipAction<T>(this ActionQueue<T> target) where T : class
        {
            target.Actions.Enqueue(target.Actions.Dequeue());
            return target;
        }

    }
}
